package xin.marcher.module.rights.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import xin.marcher.module.common.core.PageResult;
import xin.marcher.module.rights.domain.dto.RoleDTO;
import xin.marcher.module.rights.domain.entity.RoleDO;
import xin.marcher.module.rights.domain.request.RoleRequest;

/**
 *
 */
@Mapper(componentModel = "spring")
public interface RoleConverter {

    @Mapping(target = "updateUser", source = "operateUser")
    RoleDO convertDO(RoleRequest request);

    RoleDTO convertDTO(RoleDO roleDO);

    @Mappings({
            @Mapping(target = "content", source = "records"),
            @Mapping(target = "totalElements", source = "total"),
            @Mapping(target = "number", source = "current"),
            @Mapping(target = "totalPages", source = "pages"),
    })
    PageResult<RoleDTO> convertDTOs(Page<RoleDO> pageResult);

}
